#coding=utf-8
#Boa:FramePanel:PanelProfitProduct
# 财务报表 - 商品利润评估

import wx
from MyListCtrl import MySimpleListCtrl

from product import CDataProfitProduct
import kit

[wxID_PANELPROFITPRODUCT, wxID_PANELPROFITPRODUCTBTNDEL, 
 wxID_PANELPROFITPRODUCTBTNMODIFY, wxID_PANELPROFITPRODUCTBTNRECALC, 
 wxID_PANELPROFITPRODUCTBTNSAVE, wxID_PANELPROFITPRODUCTDATEEND, 
 wxID_PANELPROFITPRODUCTDATESTART, wxID_PANELPROFITPRODUCTSTATICTEXT1, 
 wxID_PANELPROFITPRODUCTSTATICTEXT10, wxID_PANELPROFITPRODUCTSTATICTEXT11, 
 wxID_PANELPROFITPRODUCTSTATICTEXT12, wxID_PANELPROFITPRODUCTSTATICTEXT13, 
 wxID_PANELPROFITPRODUCTSTATICTEXT14, wxID_PANELPROFITPRODUCTSTATICTEXT15, 
 wxID_PANELPROFITPRODUCTSTATICTEXT16, wxID_PANELPROFITPRODUCTSTATICTEXT17, 
 wxID_PANELPROFITPRODUCTSTATICTEXT18, wxID_PANELPROFITPRODUCTSTATICTEXT19, 
 wxID_PANELPROFITPRODUCTSTATICTEXT2, wxID_PANELPROFITPRODUCTSTATICTEXT20, 
 wxID_PANELPROFITPRODUCTSTATICTEXT21, wxID_PANELPROFITPRODUCTSTATICTEXT22, 
 wxID_PANELPROFITPRODUCTSTATICTEXT23, wxID_PANELPROFITPRODUCTSTATICTEXT24, 
 wxID_PANELPROFITPRODUCTSTATICTEXT25, wxID_PANELPROFITPRODUCTSTATICTEXT26, 
 wxID_PANELPROFITPRODUCTSTATICTEXT27, wxID_PANELPROFITPRODUCTSTATICTEXT28, 
 wxID_PANELPROFITPRODUCTSTATICTEXT29, wxID_PANELPROFITPRODUCTSTATICTEXT3, 
 wxID_PANELPROFITPRODUCTSTATICTEXT30, wxID_PANELPROFITPRODUCTSTATICTEXT4, 
 wxID_PANELPROFITPRODUCTSTATICTEXT5, wxID_PANELPROFITPRODUCTSTATICTEXT6, 
 wxID_PANELPROFITPRODUCTSTATICTEXT7, wxID_PANELPROFITPRODUCTSTATICTEXT8, 
 wxID_PANELPROFITPRODUCTSTATICTEXT9, wxID_PANELPROFITPRODUCTSTCOSTPERCENT, 
 wxID_PANELPROFITPRODUCTSTDAILYEMPLOYEE, 
 wxID_PANELPROFITPRODUCTSTDAILYEXPENSE, 
 wxID_PANELPROFITPRODUCTSTDAILYGROSSPROFIT, 
 wxID_PANELPROFITPRODUCTSTDAILYINVEST, 
 wxID_PANELPROFITPRODUCTSTDAILYNETPROFIT, wxID_PANELPROFITPRODUCTSTDAILYOIL, 
 wxID_PANELPROFITPRODUCTSTDAILYOTHER, wxID_PANELPROFITPRODUCTSTDAILYRENT, 
 wxID_PANELPROFITPRODUCTSTDAILYSALES, wxID_PANELPROFITPRODUCTSTDAILYTRUCK, 
 wxID_PANELPROFITPRODUCTSTDAYS, wxID_PANELPROFITPRODUCTSTGROSSPERCENT, 
 wxID_PANELPROFITPRODUCTSTNETPERCENT, wxID_PANELPROFITPRODUCTTCCOST, 
 wxID_PANELPROFITPRODUCTTCDISCOUNT, wxID_PANELPROFITPRODUCTTCEMPLOYEE, 
 wxID_PANELPROFITPRODUCTTCEXPENSE, wxID_PANELPROFITPRODUCTTCGROSSPROFIT, 
 wxID_PANELPROFITPRODUCTTCINVEST, wxID_PANELPROFITPRODUCTTCMEMO, 
 wxID_PANELPROFITPRODUCTTCNETPROFIT, wxID_PANELPROFITPRODUCTTCOIL, 
 wxID_PANELPROFITPRODUCTTCOTHEREXPENSE, wxID_PANELPROFITPRODUCTTCRENT, 
 wxID_PANELPROFITPRODUCTTCSALES, wxID_PANELPROFITPRODUCTTCTRUCK, 
] = [wx.NewId() for _init_ctrls in range(64)]

class PanelProfitProduct(wx.Panel):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Panel.__init__(self, id=wxID_PANELPROFITPRODUCT,
              name=u'PanelProfitProduct', parent=prnt, pos=wx.Point(756, 282),
              size=wx.Size(1017, 736), style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(1001, 698))
        self.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'\u6977\u4f53_GB2312'))
        self.SetBackgroundColour(wx.Colour(183, 209, 173))

        self.staticText1 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT1,
              label=u'\u5546\u54c1\u5229\u6da6\u8bc4\u4f30\u8868',
              name='staticText1', parent=self, pos=wx.Point(176, 16),
              size=wx.Size(119, 16), style=0)

        self.staticText2 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT2,
              label=u'\u8d77\u6b62\u65e5\u671f', name='staticText2',
              parent=self, pos=wx.Point(48, 64), size=wx.Size(68, 16), style=0)

        self.dateStart = wx.DatePickerCtrl(id=wxID_PANELPROFITPRODUCTDATESTART,
              name=u'dateStart', parent=self, pos=wx.Point(136, 56),
              size=wx.Size(121, 24), style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        self.dateStart.Bind(wx.EVT_DATE_CHANGED, self.OnDateStartDateChanged,
              id=wxID_PANELPROFITPRODUCTDATESTART)

        self.staticText3 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT3,
              label=u'\u81f3', name='staticText3', parent=self,
              pos=wx.Point(264, 64), size=wx.Size(17, 16), style=0)

        self.dateEnd = wx.DatePickerCtrl(id=wxID_PANELPROFITPRODUCTDATEEND,
              name=u'dateEnd', parent=self, pos=wx.Point(296, 56),
              size=wx.Size(121, 24), style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
        self.dateEnd.Bind(wx.EVT_DATE_CHANGED, self.OnDateEndDateChanged,
              id=wxID_PANELPROFITPRODUCTDATEEND)

        self.btnRecalc = wx.Button(id=wxID_PANELPROFITPRODUCTBTNRECALC,
              label=u'\u8ba1\u7b97', name=u'btnRecalc', parent=self,
              pos=wx.Point(424, 56), size=wx.Size(93, 26), style=0)
        self.btnRecalc.Bind(wx.EVT_BUTTON, self.OnBtnRecalcButton,
              id=wxID_PANELPROFITPRODUCTBTNRECALC)

        self.btnSave = wx.Button(id=wxID_PANELPROFITPRODUCTBTNSAVE,
              label=u'\u4fdd\u5b58\u65b0\u8868', name=u'btnSave', parent=self,
              pos=wx.Point(760, 56), size=wx.Size(93, 26), style=0)
        self.btnSave.Bind(wx.EVT_BUTTON, self.OnBtnSaveButton,
              id=wxID_PANELPROFITPRODUCTBTNSAVE)

        self.btnDel = wx.Button(id=wxID_PANELPROFITPRODUCTBTNDEL,
              label=u'\u5220\u9664', name=u'btnDel', parent=self,
              pos=wx.Point(864, 56), size=wx.Size(93, 26), style=0)
        self.btnDel.Bind(wx.EVT_BUTTON, self.OnBtnDelButton,
              id=wxID_PANELPROFITPRODUCTBTNDEL)

        self.staticText4 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT4,
              label=u'\u4e00\u3001\u5546\u54c1\u9500\u552e\u6bdb\u5229\u6da6',
              name='staticText4', parent=self, pos=wx.Point(56, 104),
              size=wx.Size(153, 16), style=0)

        self.tcGrossProfit = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCGROSSPROFIT,
              name=u'tcGrossProfit', parent=self, pos=wx.Point(224, 96),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcGrossProfit.Enable(False)
        self.tcGrossProfit.Bind(wx.EVT_TEXT, self.OnTcGrossProfitText,
              id=wxID_PANELPROFITPRODUCTTCGROSSPROFIT)

        self.tcSales = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCSALES,
              name=u'tcSales', parent=self, pos=wx.Point(224, 128),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcSales.Bind(wx.EVT_TEXT, self.OnTcSalesText,
              id=wxID_PANELPROFITPRODUCTTCSALES)

        self.staticText5 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT5,
              label=u'\u5546\u54c1\u9500\u552e\u91d1\u989d', name='staticText5',
              parent=self, pos=wx.Point(80, 136), size=wx.Size(102, 19),
              style=0)

        self.staticText6 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT6,
              label=u'\u51cf\uff1a\u5546\u54c1\u91c7\u8d2d\u6210\u672c',
              name='staticText6', parent=self, pos=wx.Point(80, 168),
              size=wx.Size(136, 16), style=0)

        self.tcCost = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCCOST,
              name=u'tcCost', parent=self, pos=wx.Point(224, 160),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcCost.Bind(wx.EVT_TEXT, self.OnTcCostText,
              id=wxID_PANELPROFITPRODUCTTCCOST)

        self.tcDiscount = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCDISCOUNT,
              name=u'tcDiscount', parent=self, pos=wx.Point(224, 192),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcDiscount.Bind(wx.EVT_TEXT, self.OnTcDiscountText,
              id=wxID_PANELPROFITPRODUCTTCDISCOUNT)

        self.staticText7 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT7,
              label=u'\u51cf\uff1a\u8ba2\u5355\u6298\u6263', name='staticText7',
              parent=self, pos=wx.Point(80, 200), size=wx.Size(102, 16),
              style=0)

        self.staticText8 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT8,
              label=u'\u4e8c\u3001\u8fd0\u8425\u6210\u672c', name='staticText8',
              parent=self, pos=wx.Point(56, 232), size=wx.Size(102, 16),
              style=0)

        self.tcExpense = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCEXPENSE,
              name=u'tcExpense', parent=self, pos=wx.Point(224, 224),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcExpense.Enable(False)
        self.tcExpense.Bind(wx.EVT_TEXT, self.OnTcExpenseText,
              id=wxID_PANELPROFITPRODUCTTCEXPENSE)

        self.tcEmployee = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCEMPLOYEE,
              name=u'tcEmployee', parent=self, pos=wx.Point(224, 256),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcEmployee.Bind(wx.EVT_TEXT, self.OnTcEmployeeText,
              id=wxID_PANELPROFITPRODUCTTCEMPLOYEE)

        self.staticText9 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT9,
              label=u'\u5458\u5de5\u652f\u51fa', name='staticText9',
              parent=self, pos=wx.Point(80, 264), size=wx.Size(68, 16),
              style=0)

        self.staticText10 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT10,
              label=u'\u6cb9\u8d39\u5dee\u65c5', name='staticText10',
              parent=self, pos=wx.Point(80, 296), size=wx.Size(68, 16),
              style=0)

        self.tcOil = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCOIL, name=u'tcOil',
              parent=self, pos=wx.Point(224, 288), size=wx.Size(152, 26),
              style=wx.TE_RIGHT, value=u'')
        self.tcOil.Bind(wx.EVT_TEXT, self.OnTcOilText,
              id=wxID_PANELPROFITPRODUCTTCOIL)

        self.tcTruck = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCTRUCK,
              name=u'tcTruck', parent=self, pos=wx.Point(224, 320),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcTruck.Enable(True)
        self.tcTruck.Bind(wx.EVT_TEXT, self.OnTcTruckText,
              id=wxID_PANELPROFITPRODUCTTCTRUCK)

        self.staticText13 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT13,
              label=u'\u8f66\u8f86\u7ef4\u4fdd', name='staticText13',
              parent=self, pos=wx.Point(80, 328), size=wx.Size(68, 16),
              style=0)

        self.staticText14 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT14,
              label=u'\u6295\u8d44\u5f00\u652f', name='staticText14',
              parent=self, pos=wx.Point(80, 360), size=wx.Size(68, 16),
              style=0)

        self.tcInvest = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCINVEST,
              name=u'tcInvest', parent=self, pos=wx.Point(224, 352),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcInvest.Bind(wx.EVT_TEXT, self.OnTcInvestText,
              id=wxID_PANELPROFITPRODUCTTCINVEST)

        self.tcOtherExpense = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCOTHEREXPENSE,
              name=u'tcOtherExpense', parent=self, pos=wx.Point(224, 384),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcOtherExpense.Bind(wx.EVT_TEXT, self.OnTcOtherExpenseText,
              id=wxID_PANELPROFITPRODUCTTCOTHEREXPENSE)

        self.staticText11 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT11,
              label=u'\u5176\u4ed6\u5f00\u652f', name='staticText11',
              parent=self, pos=wx.Point(80, 392), size=wx.Size(68, 16),
              style=0)

        self.staticText12 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT12,
              label=u'\u5f53\u671f\u623f\u79df', name='staticText12',
              parent=self, pos=wx.Point(80, 424), size=wx.Size(68, 16),
              style=0)

        self.tcRent = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCRENT,
              name=u'tcRent', parent=self, pos=wx.Point(224, 416),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcRent.Enable(True)
        self.tcRent.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)
        self.tcRent.SetBackgroundColour(wx.Colour(186, 255, 117))
        self.tcRent.Bind(wx.EVT_TEXT, self.OnTcRentText,
              id=wxID_PANELPROFITPRODUCTTCRENT)

        self.staticText16 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT16,
              label=u'\u56db\u3001\u51c0\u5229\u6da6\u8bc4\u4f30',
              name='staticText16', parent=self, pos=wx.Point(56, 456),
              size=wx.Size(119, 16), style=0)

        self.tcNetProfit = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCNETPROFIT,
              name=u'tcNetProfit', parent=self, pos=wx.Point(224, 448),
              size=wx.Size(152, 26), style=wx.TE_RIGHT, value=u'')
        self.tcNetProfit.Enable(False)
        self.tcNetProfit.Bind(wx.EVT_TEXT, self.OnTcNetProfitText,
              id=wxID_PANELPROFITPRODUCTTCNETPROFIT)

        self.tcMemo = wx.TextCtrl(id=wxID_PANELPROFITPRODUCTTCMEMO,
              name=u'tcMemo', parent=self, pos=wx.Point(56, 496),
              size=wx.Size(912, 152), style=wx.TE_MULTILINE, value=u'')

        self.stNetPercent = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTNETPERCENT,
              label=u'%', name=u'stNetPercent', parent=self, pos=wx.Point(384,
              472), size=wx.Size(64, 16), style=0)

        self.stGrossPercent = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTGROSSPERCENT,
              label=u'%', name=u'stGrossPercent', parent=self, pos=wx.Point(384,
              112), size=wx.Size(56, 16), style=0)

        self.stCostPercent = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTCOSTPERCENT,
              label=u'%', name=u'stCostPercent', parent=self, pos=wx.Point(384,
              240), size=wx.Size(40, 16), style=0)

        self.staticText15 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT15,
              label=u'\u5165\u5e93\u4ef7', name='staticText15', parent=self,
              pos=wx.Point(384, 168), size=wx.Size(51, 16), style=0)

        self.btnModify = wx.Button(id=wxID_PANELPROFITPRODUCTBTNMODIFY,
              label=u'\u4fdd\u5b58\u4fee\u6539', name=u'btnModify', parent=self,
              pos=wx.Point(864, 24), size=wx.Size(93, 26), style=0)
        self.btnModify.Bind(wx.EVT_BUTTON, self.OnBtnModifyButton,
              id=wxID_PANELPROFITPRODUCTBTNMODIFY)

        self.staticText17 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT17,
              label=u'\u6bdb\u5229\u7387=\u6bdb\u5229/\u9500\u552e',
              name='staticText17', parent=self, pos=wx.Point(384, 88),
              size=wx.Size(137, 16), style=0)

        self.staticText18 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT18,
              label=u'\u6210\u672c\u7ebf=\u8d39\u7528/\u6210\u672c(\u4e0d\u542b\u6295\u8d44)',
              name='staticText18', parent=self, pos=wx.Point(384, 216),
              size=wx.Size(223, 16), style=0)

        self.staticText19 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT19,
              label=u'\u51c0\u5229\u7387=\u51c0\u5229/\u9500\u552e',
              name='staticText19', parent=self, pos=wx.Point(384, 448),
              size=wx.Size(137, 16), style=0)

        self.staticText20 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT20,
              label=u'\u65e5\u5747\uff1a', name='staticText20', parent=self,
              pos=wx.Point(440, 240), size=wx.Size(51, 16), style=0)

        self.stDailyExpense = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYEXPENSE,
              label=u'0', name=u'stDailyExpense', parent=self, pos=wx.Point(496,
              240), size=wx.Size(56, 16), style=0)

        self.staticText21 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT21,
              label=u'\u65e5\u5747\uff1a', name='staticText21', parent=self,
              pos=wx.Point(384, 264), size=wx.Size(51, 16), style=0)

        self.stDailyEmployee = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYEMPLOYEE,
              label=u'0', name=u'stDailyEmployee', parent=self,
              pos=wx.Point(440, 264), size=wx.Size(64, 16), style=0)

        self.staticText22 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT22,
              label=u'\u65e5\u5747\uff1a', name='staticText22', parent=self,
              pos=wx.Point(384, 296), size=wx.Size(51, 16), style=0)

        self.stDailyOil = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYOIL,
              label=u'0', name=u'stDailyOil', parent=self, pos=wx.Point(440,
              296), size=wx.Size(64, 16), style=0)

        self.staticText23 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT23,
              label=u'\u65e5\u5747\uff1a', name='staticText23', parent=self,
              pos=wx.Point(384, 328), size=wx.Size(51, 16), style=0)

        self.stDailyTruck = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYTRUCK,
              label=u'0', name=u'stDailyTruck', parent=self, pos=wx.Point(440,
              328), size=wx.Size(64, 16), style=0)

        self.staticText24 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT24,
              label=u'\u65e5\u5747\uff1a', name='staticText24', parent=self,
              pos=wx.Point(384, 360), size=wx.Size(51, 16), style=0)

        self.stDailyInvest = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYINVEST,
              label=u'0', name=u'stDailyInvest', parent=self, pos=wx.Point(440,
              360), size=wx.Size(64, 16), style=0)

        self.staticText25 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT25,
              label=u'\u65e5\u5747\uff1a', name='staticText25', parent=self,
              pos=wx.Point(384, 392), size=wx.Size(51, 16), style=0)

        self.stDailyOther = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYOTHER,
              label=u'0', name=u'stDailyOther', parent=self, pos=wx.Point(440,
              392), size=wx.Size(64, 16), style=0)

        self.staticText27 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT27,
              label=u'\u65e5\u5747\uff1a', name='staticText27', parent=self,
              pos=wx.Point(384, 424), size=wx.Size(51, 16), style=0)

        self.stDailyRent = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYRENT,
              label=u'0', name=u'stDailyRent', parent=self, pos=wx.Point(440,
              424), size=wx.Size(64, 16), style=0)

        self.staticText26 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT26,
              label=u'\u65e5\u5747\uff1a', name='staticText26', parent=self,
              pos=wx.Point(448, 472), size=wx.Size(51, 16), style=0)

        self.staticText28 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT28,
              label=u'\u65e5\u5747\uff1a', name='staticText28', parent=self,
              pos=wx.Point(440, 112), size=wx.Size(51, 16), style=0)

        self.staticText29 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT29,
              label=u'\u65e5\u5747\uff1a', name='staticText29', parent=self,
              pos=wx.Point(384, 136), size=wx.Size(51, 16), style=0)

        self.stDailySales = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYSALES,
              label=u'0', name=u'stDailySales', parent=self, pos=wx.Point(440,
              136), size=wx.Size(72, 16), style=0)

        self.staticText30 = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTATICTEXT30,
              label=u'\u5929\u6570\uff1a', name='staticText30', parent=self,
              pos=wx.Point(528, 64), size=wx.Size(51, 16), style=0)

        self.stDays = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAYS,
              label=u'1', name=u'stDays', parent=self, pos=wx.Point(584, 64),
              size=wx.Size(9, 16), style=0)

        self.stDailyGrossProfit = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYGROSSPROFIT,
              label=u'0', name=u'stDailyGrossProfit', parent=self,
              pos=wx.Point(496, 112), size=wx.Size(9, 16), style=0)

        self.stDailyNetProfit = wx.StaticText(id=wxID_PANELPROFITPRODUCTSTDAILYNETPROFIT,
              label=u'0', name=u'stDailyNetProfit', parent=self,
              pos=wx.Point(504, 472), size=wx.Size(9, 16), style=0)

    def __init__(self, parent):
        self._init_ctrls(parent)

        self.curObj = None

        self.dateStart.SetValue(wx.DateTime.Today())
        self.dateEnd.SetValue(wx.DateTime.Today())

        cols = [(CDataProfitProduct.fi_id, wx.LIST_FORMAT_LEFT, 110),
                (CDataProfitProduct.fi_Cost, wx.LIST_FORMAT_RIGHT, 100),
                (CDataProfitProduct.fi_NetProfit, wx.LIST_FORMAT_RIGHT, 100)]
                
        #self.listCtrl  = MyListCtrlDecorator(self.lc, cols, CDataCustomerRegion)
        
        self.lc = MySimpleListCtrl(self, CDataProfitProduct, cols)
        self.lc.Move(wx.Point(610, 96))
        self.lc.SetSize(wx.Size(360, 380))
        #self.lc.refresh()
        self.lc.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnListItemSelected)

        self.btnModify.Enable(False)
        self.btnDel.Enable(False)
        
    def OnListItemSelected(self, event):
        item = self.lc.GetNextItem(-1, state = wx.LIST_STATE_SELECTED)
        if (item == -1):
            return

        self.curObj = CDataProfitProduct.getData({"id":self.lc.GetItemText(item)})
        self.ShowData()

        self.btnModify.Enable(True)
        self.btnDel.Enable(True)

    def ShowData(self):
        obj = self.curObj
        
        date = obj.getValue(obj.fi_dateStart)
        #self.dateStart.SetValue(date)
        self.dateStart.SetValue(wx.DateTimeFromDMY(date.day, date.month-1, date.year,0,0,0))
        date = obj.getValue(obj.fi_dateEnd)
        #self.dateEnd.SetValue(date)
        self.dateEnd.SetValue(wx.DateTimeFromDMY(date.day, date.month-1, date.year,0,0,0))
        self.stDays.SetLabel("%d" %self.GetDays())

        self.tcGrossProfit.SetValue("%.0f" %(obj.getValue(obj.fi_GrossProfit)))
        self.tcSales.SetValue("%.0f" %(obj.getValue(obj.fi_Sales)))
        self.tcCost.SetValue("%.0f" %(obj.getValue(obj.fi_Cost)))
        self.tcDiscount.SetValue("%.0f" %(obj.getValue(obj.fi_Discount)))
        self.tcExpense.SetValue("%.0f" %(obj.getValue(obj.fi_Expense)))
        self.tcEmployee.SetValue("%.0f" %(obj.getValue(obj.fi_Employee)))
        self.tcOil.SetValue("%.0f" %(obj.getValue(obj.fi_Oil)))
        self.tcTruck.SetValue("%.0f" %(obj.getValue(obj.fi_Truck)))
        self.tcInvest.SetValue("%.0f" %(obj.getValue(obj.fi_Invest)))
        self.tcOtherExpense.SetValue("%.0f" %(obj.getValue(obj.fi_OtherExpense)))
        self.tcRent.SetValue("%.0f" %(obj.getValue(obj.fi_Rent)))
        self.tcNetProfit.SetValue("%.0f" %(obj.getValue(obj.fi_NetProfit)))
        self.tcMemo.SetValue(obj.getValue(obj.fi_Memo))

    def getData(self):

        data = {
            CDataProfitProduct.fi_dateStart : kit.str2Date(self.dateStart.GetValue().Format('%Y-%m-%d')),
            CDataProfitProduct.fi_dateEnd : kit.str2Date(self.dateEnd.GetValue().Format('%Y-%m-%d')),
            CDataProfitProduct.fi_GrossProfit : kit.toFloatOrZero(self.tcGrossProfit.GetValue()),
            CDataProfitProduct.fi_Sales : kit.toFloatOrZero(self.tcSales.GetValue()),
            CDataProfitProduct.fi_Cost : kit.toFloatOrZero(self.tcCost.GetValue()),
            CDataProfitProduct.fi_Discount : kit.toFloatOrZero(self.tcDiscount.GetValue()),
            CDataProfitProduct.fi_Expense : kit.toFloatOrZero(self.tcExpense.GetValue()),
            CDataProfitProduct.fi_Employee : kit.toFloatOrZero(self.tcEmployee.GetValue()),
            CDataProfitProduct.fi_Oil : kit.toFloatOrZero(self.tcOil.GetValue()),
            CDataProfitProduct.fi_Truck : kit.toFloatOrZero(self.tcTruck.GetValue()),
            CDataProfitProduct.fi_Invest : kit.toFloatOrZero(self.tcInvest.GetValue()),
            CDataProfitProduct.fi_OtherExpense : kit.toFloatOrZero(self.tcOtherExpense.GetValue()),
            CDataProfitProduct.fi_Rent : kit.toFloatOrZero(self.tcRent.GetValue()),
            CDataProfitProduct.fi_NetProfit : kit.toFloatOrZero(self.tcNetProfit.GetValue()),
            CDataProfitProduct.fi_Memo : self.tcMemo.GetValue(),
        }

        return data

    def OnBtnRecalcButton(self, event):
        '''按日期计算数据'''

        dateStart = self.dateStart.GetValue().Format('%Y-%m-%d')
        dateEnd = self.dateEnd.GetValue().Format('%Y-%m-%d')

        sales,cost = CDataProfitProduct.GetSales(dateStart, dateEnd)
        discount = CDataProfitProduct.GetDiscount(dateStart, dateEnd)
        employee, truck, oil, invest, other = CDataProfitProduct.GetExpense(dateStart, dateEnd)

        self.tcSales.SetValue('%.0f' %(sales or 0))
        self.tcDiscount.SetValue('%.0f' %(discount or 0))
        self.tcCost.SetValue('%.0f' %(cost or 0))
        self.tcEmployee.SetValue('%.0f' %(employee or 0))
        self.tcOil.SetValue('%.0f' %(oil or 0))
        self.tcTruck.SetValue('%.0f' %(truck or 0))
        self.tcInvest.SetValue('%.0f' %(invest or 0))
        self.tcOtherExpense.SetValue('%.0f' %(other or 0))

    def OnBtnSaveButton(self, event):
        #if self.curObj is None:
        #    return

        import datetime

        if (self.tcSales.GetValue() == ""):
            return
                
        dlg = wx.TextEntryDialog(self, u'输入表名',
                                u'输入表名',self.dateStart.GetValue().Format('%Y%m%d'),wx.OK|wx.CANCEL|wx.CENTRE)
        if dlg.ShowModal() != wx.ID_OK:
            return
        name = dlg.GetValue()
        
        data = self.getData()
        data[CDataProfitProduct.fi_id] = name
        
        obj = CDataProfitProduct.factory()
        obj.setMulFieldVal(data)
        obj.insert()
        self.curObj = obj

        self.lc.refresh()

    def OnBtnDelButton(self, event):
        ''' 删除选中记录 '''
        if self.curObj is not None:
            self.curObj.delete()
            self.lc.refresh()

    def RecalcGrossPercent(self):
        '''重算 毛利率'''
        
        grossProfit = kit.toFloatOrZero(self.tcGrossProfit.GetValue())
        #cost = kit.toFloatOrZero(self.tcCost.GetValue())
        sales = kit.toFloatOrZero(self.tcSales.GetValue())
        if (sales > 0):
            self.stGrossPercent.SetLabel('%.0f%%' %(grossProfit*100/sales))

    def RecalcNetPercent(self):
        '''重算 净利率'''

        netProfit = kit.toFloatOrZero(self.tcNetProfit.GetValue())
        #cost = kit.toFloatOrZero(self.tcCost.GetValue())
        sales = kit.toFloatOrZero(self.tcSales.GetValue())
        if (sales > 0):
            self.stNetPercent.SetLabel('%.0f%%' %(netProfit*100/sales))

    def RecalcCostPercent(self):
        '''重算 成本线'''
        expense = kit.toFloatOrZero(self.tcExpense.GetValue())
        invest = kit.toFloatOrZero(self.tcInvest.GetValue())
        #sales = kit.toFloatOrZero(self.tcSales.GetValue())
        cost = kit.toFloatOrZero(self.tcCost.GetValue())
        if (cost > 0):
            self.stCostPercent.SetLabel('%.0f%%' %((expense-invest)*100/cost))

    def RecalcGrossProfit(self):
        ''' 重算毛利润 '''
        sales = kit.toFloatOrZero(self.tcSales.GetValue())
        discount = kit.toFloatOrZero(self.tcDiscount.GetValue())
        cost = kit.toFloatOrZero(self.tcCost.GetValue())
        
        GrossProfit = sales - discount - cost
        self.tcGrossProfit.SetValue('%.0f' %(GrossProfit))

    def RecalcExpense(self):
        ''' 重算运营成本 '''
        employee = kit.toFloatOrZero(self.tcEmployee.GetValue())
        oil = kit.toFloatOrZero(self.tcOil.GetValue())
        truck = kit.toFloatOrZero(self.tcTruck.GetValue())
        rent = kit.toFloatOrZero(self.tcRent.GetValue())
        invest = kit.toFloatOrZero(self.tcInvest.GetValue())
        other = kit.toFloatOrZero(self.tcOtherExpense.GetValue())
        expense = employee + oil + truck + rent + invest + other
        self.tcExpense.SetValue('%.0f' %(expense))

    def RecalcNetProfit(self):
        ''' 重算净利润 '''
        GrossProfit = kit.toFloatOrZero(self.tcGrossProfit.GetValue())
        expense = kit.toFloatOrZero(self.tcExpense.GetValue())

        NetProfit = GrossProfit - expense
        self.tcNetProfit.SetValue('%.0f' %(NetProfit))


    def OnTcGrossProfitText(self, event):
        self.RecalcGrossPercent()
        self.RecalcNetProfit()

        self.stDailyGrossProfit.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcGrossProfit.GetValue())/self.GetDays()))

    def OnTcSalesText(self, event):
        self.RecalcGrossProfit()

        #self.RecalcNetPercent()
        self.stDailySales.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcSales.GetValue())/self.GetDays()))

    def OnTcDiscountText(self, event):
        self.RecalcGrossProfit()

    def OnTcCostText(self, event):
        self.RecalcGrossProfit()

        self.RecalcCostPercent()

    def OnTcExpenseText(self, event):
        self.RecalcNetProfit()

        self.RecalcCostPercent()

        self.stDailyExpense.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcExpense.GetValue())/self.GetDays()))

    def OnTcEmployeeText(self, event):
        self.RecalcExpense()
        self.stDailyEmployee.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcEmployee.GetValue())/self.GetDays()))

    def OnTcOilText(self, event):
        self.RecalcExpense()
        self.stDailyOil.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcOil.GetValue())/self.GetDays()))

    def OnTcTruckText(self, event):
        self.RecalcExpense()
        self.stDailyTruck.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcTruck.GetValue())/self.GetDays()))

    def OnTcInvestText(self, event):
        self.RecalcExpense()
        self.stDailyInvest.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcInvest.GetValue())/self.GetDays()))

    def OnTcOtherExpenseText(self, event):
        self.RecalcExpense()
        self.stDailyOther.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcOtherExpense.GetValue())/self.GetDays()))

    def OnTcRentText(self, event):
        self.RecalcExpense()
        self.stDailyRent.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcRent.GetValue())/self.GetDays()))

    def OnTcNetProfitText(self, event):
        self.RecalcNetPercent()
        self.stDailyNetProfit.SetLabel("%.0f" %(kit.toFloatOrZero(self.tcNetProfit.GetValue())/self.GetDays()))

    def OnBtnModifyButton(self, event):
        ''' 保存修改 '''

        if self.curObj is None:
            return

        dlg = wx.MessageDialog(self, u'是否覆盖原记录？',u'提示',
                                    wx.YES_NO|wx.ICON_QUESTION)
        if(dlg.ShowModal() == wx.ID_NO):
            return

        self.curObj.setMulFieldVal(self.getData())
        self.curObj.update()
        
    def GetDays(self):
        span = self.dateEnd.GetValue() - self.dateStart.GetValue()
        return span.GetDays() + 1

    def OnDateStartDateChanged(self, event):
                
        self.stDays.SetLabel("%d" %self.GetDays())

    def OnDateEndDateChanged(self, event):
    
        self.stDays.SetLabel("%d" %self.GetDays())


